package common.system.service;

import java.util.List;

import common.system.bean.City;
import common.system.dao.CityDao;

public class CityServiceImpl implements CityService {
	private CityDao cityDao;
	@Override
	public List<City> getAllCity() {
		return cityDao.loadAll();
	}

	@Override
	public City getCityByID(int id) {
		return this.cityDao.get(id);
	}

	@Override
	public boolean addCity(City city) {
		Integer id = this.cityDao.save(city);
		if(id!=null && id.intValue()>0){
			return true;
		}
		return false;
	}

	@Override
	public boolean updateCity(City city) {
		this.cityDao.update(city);
		return true;
	}

	@Override
	public List<City> getCityByShortName(String shortName) {
		return this.cityDao.find("from City c where c.shortName='"+shortName+"'");
	}
	@Override
	public List<City> getCityByName(String name) {
		return this.cityDao.find("from City c where c.cityName='"+name+"'");
	}
	//=======================getter setter方法
	public CityDao getCityDao() {
		return cityDao;
	}

	public void setCityDao(CityDao cityDao) {
		this.cityDao = cityDao;
	}
	
}
